package com.mtiiot.fsmanage.controller;


import com.mtiiot.fsmanage.server.FastdfsServer;
import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * Created by Administrator on 16-8-18.
 */


@Controller
public class FastdfsController {
    @Autowired
    FastdfsServer fastdfsServer;


    /**
     * 查询ftp数据
     * @return
     */
    @RequestMapping(value="/fastdfs/fastdfsQuery.action",produces="application/json;charset=UTF-8")
    @ResponseBody
    public Object fastdfsQuery(String sysName,String l1Name,String l2Name,String l3Name,String times,String queryKeyWord,int count,String sort)throws Exception{
        Object obj = fastdfsServer.fastdfsQuery(sysName ,l1Name ,l2Name ,l3Name ,times ,queryKeyWord ,count ,sort);
        ObjectMapper mapper = new ObjectMapper();
        String jsonStr = mapper.writeValueAsString(obj);
        return jsonStr;
    }

    /**
     * 查询ftp数据
     */
    @RequestMapping(value="/fastdfs/fastdfsStatistics.action",produces="application/json;charset=UTF-8")
    @ResponseBody
    public Object fastdfsStatistics(String sysName,String l1Name,String l2Name,String l3Name,String times) throws Exception {
        Object obj=fastdfsServer.fastdfsStatistics(sysName, l1Name, l2Name, l3Name, times);
        ObjectMapper mapper = new ObjectMapper();
        String jsonStr=mapper.writeValueAsString(obj);
        System.out.println(jsonStr);
        return jsonStr;
    }
}
